{% extends 'base.html' %}

{% block title %} Tasks {% endblock %}

{% block include %} 
	<script>
		$(function() {
			initTasks();
		});
	</script>
{% endblock %}

{% block content %}

<div class="criteria">
	<b> Task Search: </b>
	<br>
	<div id="task_search_crit">
		<form id="search_form" action='/tasks/' method="get">
			<div id="criteria_fields">
				<div> <label for="id_task_name"> Task Name: </label> {{ criteria.task_name }} </div>
				<div> <label for="id_ description"> Description: </label> {{ criteria.description }} </div>
				<div> <label for="id_project"> Project: </label> {{ criteria.project }} </div>
				<div> <label for="id_sprint"> Sprint: </label> {{ criteria.sprint }} </div>
				<div> <label for="id_type"> Type: </label> {{ criteria.type }} </div>
				<div> <label for="id_status"> Status: </label> {{ criteria.status }} </div>
				<div> <label for="id_priority"> Priority: </label> {{ criteria.priority }} </div>
				<div> <label for="id_users"> Users: </label> {{ criteria.users }} </div>
			</div>
			<div> <input type="submit" value="Search">  </div>
		</form>
		<br/>
		<div id="from_saved_crit">
			<label for="id_criteria_select" > Saved Criteria: </label>
			<select name="criteria_select" id="id_criteria_select"> 
				<option value {% if cid == None %} selected="selected" {% endif %}> --------- </option>
				{% for sc in saved%}
					<option value="{{ sc.pk }}" {% if cid == sc.pk %} selected="selected" {% endif %} > {{ sc.name }} </option>
				{% endfor %}
			</select>
		</div>
		<button id="save"> Save Criteria </button>
		<div id="criteria_save" style="display:none;">
			<form id="save_form" action='/tasks/' method="post"> {% csrf_token %}
				<div id="criteria_fields_save"style="display:none;" > </div>
				<div>
					<label for="id_name"> Criteria Name: </label> {{ criteria.name }} 
					<input style='height:30px;' type="submit" value="Save">
				</div>
			</form>
		</div>
		
	</div>
</div>
<div class="results">
	<b>Tasks:</b>
	<table class="data-table"><tbody>
	<tr> <th>Name</th> <th>Project</th> <th>Sprint</th> <th>Type</th> <th>Status</th> <th>Priority</th> <th>View</th> <th>Edit</tH><th>Delete</th> </tr>
	{% for t in tasks %}
		<tr class={% cycle '' 'alt' %}>
			<td> {{ t.name }} </td>
			<td> <a href='/project/view/{{ t.project.pk }}'> {{ t.project }} </a> </td>
			<td> {% if t.sprint == None %} - {% else %} <a href='/sprint/view/{{ t.sprint.pk }}'> {{ t.sprint }} </a> {% endif %} </td>
			<td> {{ t.type }} </td>
			<td> {{ t.status }} </td>
			<td> {{ t.priority }} </td>
			<td> <a href='/task/view/{{t.pk}}/'> View</a> </td>
			<td> <a href='/task/edit/{{t.pk}}/'> Edit</a> </td>
			<td> <a href='/task/delete/{{t.pk}}/'> Delete</a> </td>
		</tr>
	{% endfor %}
	</tbody></table>

	<div id="add_task">	<a href="/task/new/">Add New Task</a></div>

</div>
<div style="clear:both"> </dic>
{% endblock %}